<extend name="Base/common"/>
<block name="body">
	<div class="mui-content mui-content-padded ">
	    <form class="mui-input-group login_form">
	    	<div class="mui-input-row">
	    	    <label><img src="__IMG__/icon_mobile.png"></label>
	    	    <input type="text" id="mobile" class="mui-input-clear" placeholder="手机号">
	    	</div>
	        <div class="mui-input-row">
	    	    <label><img src="__IMG__/icon_lock.png"></label>
	        	<input type="password" id="pwd" class="mui-input-password" placeholder="请输入密码">
	        </div>
	        <div class="btn_sure">
	        	<button type="button" id="btn_submit" class="mui-btn mui-btn-block btn_submit">登录</button>
	        </div>
	        
		    <div class="mui-row">
		        <div style="width: 50%;" class="mui-pull-left">
		            <a href="{:U('forget')}">找回密码?</a>
		        </div>
		        <div style="width: 50%;" class="mui-pull-right mui-text-right">
		            <a href="{:U('reg')}">注册</a>
		        </div>
		    </div>
		    <div style="text-align: center;border-top: 1px solid #ddd;border-bottom: 1px solid #ddd;margin-top: 2rem;padding: 1rem;font-size: 0.8rem">
		    	<img src="__IMG__/weixin.png" style="height: 2.5rem;" id="wx_login">
		    	<div>如已有app账号，必须使用app账号登录；若无app账号，可选择微信登录。必须保证APP和微信端登录方式一致。</div>
		    </div>
	    </form>
	</div>
</div>
</block>
<block name="script">
	<script type="text/javascript">
		$("#btn_submit").on('click',function(){
			var mobile = $("#mobile").val();
			var pwd = $("#pwd").val();
			if (mobile == '') {
				mui.alert("请输入手机号");
				return ;
			}
			$.post("{:U('/api/user/login')}",{"user":mobile,"pwd":pwd,"driver":"wap"},function(result){
				if (result.code !== 1) {
					mui.alert(result.message);
				}else{
					location.href = "{:U('Index/index')}";
				}
			},'json');
		});
		$("#wx_login").on('click',function(){
			var wx_info = {
				"type":"wx",
				"openid":"{$unionid}",
				"nickname":"{$nickname}",
				"avatar":"{$headimgurl}"
			}
			$.post("{:U('/api/user/userLoginByThird')}",wx_info,function(result){
				if (result.code !== 1) {
					mui.alert(result.message);
				}else{
					location.href = "{:U('Index/index')}?token="+result.data.token;
				}
			},'json');
		})
	</script>
</block>
